package com.titan.single.liteflow;

import cn.hutool.core.util.StrUtil;
import com.titan.single.exceptions.TitanException;
import com.titan.single.vo.BaseRequest;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

/**
 * 规则flowA
 */
@LiteflowComponent(id = "aaa", name = "预处理A")
@Slf4j
public class Aaa extends NodeComponent {


    @Override
    public void process() throws Exception {
        log.info("已进入aaa节点");
        BaseRequest request =  this.getRequestData();
        // 校验
        checkParam(request);
        // 预处理 赋值
        request.getRecord().add("已进入aaa");
    }

    private void checkParam(BaseRequest request) throws Exception {

        if (Objects.isNull(request) || StrUtil.equals(request.getIsError(),"1")){
            throw new TitanException("-1","liteFlow-aaa 失败了");
        }
    }


}
